/*
 *
 *  Copyright (C) 2010 GSyC/LibreSoft
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/. 
 *
 *  Author : Roberto Calvo Palomino <rocapal@libresoft.es>
 *
 */

package com.LibreGeoSocial.App.AlarmManager;

import java.util.ArrayList;
import java.util.Collections;

import android.location.Location;

import com.LibreGeoSocial.Api.GeoNode;
import com.LibreGeoSocial.Api.GeoNodePositionComparator;
import com.LibreGeoSocial.Api.LibreGeoSocial;

public class LocationAlarm extends GenericAlarm {

	
	public LocationAlarm(String name) {
		super(name);
	}

	@Override
	public ArrayList<GeoNode> refreshData(Location CurrentLocation) {
		
		ArrayList<GeoNode> nodeList;
		nodeList = LibreGeoSocial.getInstance().searchAllNodes(1.0, getSearchPatter() );
		
		// Sort the list by distance
		GeoNodePositionComparator comparator = new GeoNodePositionComparator();
		Collections.sort(nodeList, comparator);
		
		return nodeList;
	}

}
